package com.xwdeshj.controller;

import com.alibaba.fastjson.JSONObject;
import com.xwdeshj.service.XwSceincPlaytypeService;
import com.xwdeshj.utils.IMoocExceptionHandler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by BKWJA on 2018/12/21.
 * 景区游玩类型控制层
 */
@Slf4j
@RequestMapping("ScePlayType")
@CrossOrigin(allowCredentials = "true")
@Controller
public class XwSceincPlaytypeController  extends IMoocExceptionHandler {

    @Autowired
    private XwSceincPlaytypeService xwSceincPlaytypeService;

    //获取全部（景区）的游玩类型信息列表,不分页，按添加日期排序
    @RequestMapping("/getAllScePlaytype")
    @ResponseBody
    public JSONObject getAllScePlaytype(HttpServletRequest request){
        return  xwSceincPlaytypeService.getAllScePlaytype(request);
    }

    /**
     * 景区游玩类型列表查询
     * @param pageindex 当前页码
     * @param pagesize 每页显示多少
     * @param starttime 开始时间
     * @param endtime 结束时间
     * @param sortfild 排序字段
     * @param sortway 排序方式
     * @return
     */
    @RequestMapping("/getScePlaytypelist")
    @ResponseBody
    public JSONObject getScePlaytypelist(@RequestParam(value = "pageindex",defaultValue = "1")Integer pageindex,
                                        @RequestParam(value = "pagesize",defaultValue = "10") Integer pagesize,
                                        @RequestParam(value = "starttime",defaultValue = "") String starttime,
                                        @RequestParam(value = "endtime",defaultValue = "") String endtime,
                                        @RequestParam(value = "sortfild",defaultValue = "sceinc_playType_createtime") String sortfild,
                                        @RequestParam(value = "sortway",defaultValue = "desc")String sortway){
        return xwSceincPlaytypeService.getScePlaytypelist(pageindex,pagesize,starttime,endtime,sortfild,sortway);
    }

    /**
     * 修改，新增景区游玩类型信息
     * @param sceinc_playType_encryptId  景区游玩类型加密id
     * @param sceinc_playType_desc 景区游玩类型文字
     * @return
     */
    @RequestMapping("/updateScePlaytype")
    @ResponseBody
    public JSONObject updateScePlaytype(String sceinc_playType_encryptId,String sceinc_playType_desc){
        return xwSceincPlaytypeService.updateScePlaytype(sceinc_playType_encryptId,sceinc_playType_desc);
    }

    /**
     * 根据sceinc_playType_encryptId景区游玩类型加密id，删除对应的记录
     * @param sceinc_playType_encryptId
     * @return
     */
    @RequestMapping("/delScePlaytype")
    @ResponseBody
    public JSONObject delScePlaytype(String sceinc_playType_encryptId){
        return xwSceincPlaytypeService.delScePlaytype(sceinc_playType_encryptId);
    }

}
